package prs.hades.hessian;

import java.net.MalformedURLException;
import prs.hades.hessian.annotation.Context;
import com.caucho.hessian.client.HessianProxyFactory;

public class HessianUtil {
	private static HessianProxyFactory factory = null;

	@SuppressWarnings("unchecked")
	public static <T> T getService(Class<T> clazz, String url){
		if (null==factory) { factory = new HessianProxyFactory(); }
		try {
			url= Context.API_V2.getRemoteUrl()+url;
			return (T) factory.create(clazz, url);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
		
		return null;
	}
    
}
